home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / MAIL.SWG / 0022_New Squish List.pas < prev   
Pascal/Delphi Source File  |  1995-03-03  |  3KB  |  85 lines

  1. {
  2. From: Norman.User@telos.org (Norman User)
  3. Here is the revised NewSquishList function you need.
  4. }
  5.  
  6. Function NewSquishList(Urec,Arec:MaxRecPtr;NewOnly,ToYouOnly:Boolean):pointer;
  7.    Var
  8.      Sq : SqiColPtr;
  9.      f  : PDosStream;
  10.      fb : PBufStream;
  11.      sql: sqlType;
  12.      sqi: sqiType;
  13.      Sqp: SqiPtr;
  14.      tempN : longint;
  15.      lhn   : LongInt;
  16.      lhs   : string;
  17.      sqz   : Longint;
  18.    Begin
  19.      NewSquishList := nil;
  20.      sq    := nil;
  21.      sql   := 0;
  22.      tempN := 0;
  23.      if   NewOnly
  24.      then Begin
  25.             (***** last read message number from the SQL file *****)
  26.             New(F,init(StrPas(@MaxAreaRec(Arec^.rec^).mpath) +         
  27.                        '.SQL',StOpenRead or StDenyNone));
  28.             if   f^.status = StOk
  29.             then begin
  30.                    f^.seek(MaxUserRec(Urec^.rec^).LastRead*SizeOf(sqlType));
  31.                    if f^.status = stok then f^.read(sql,sizeof(sql));
  32.                    if f^.status <> Stok then sql := -1;
  33.                  end;
  34.             dispose(f,done);
  35.             if sql < 0 then exit;
  36.           End;
  37.      lhn := sql;
  38.      sqz := sql;
  39.      fillchar(sqi,sizeof(sqi),0);
  40.      New(fb,init(StrPas(@MaxAreaRec(Arec^.rec^).mpath) + '.SQI',StOpenRead or  
  41.                 StDenyNone,2048));
  42.      if fb^.status = StOk then fb^.read(sqi,sizeof(sqitype));
  43.      while (fb^.status = StOk) and (sqi.msgnum <= sql)
  44.      do    begin
  45.              inc(tempN);
  46.              fillchar(sqi,sizeof(sqitype),0);
  47.              fb^.read(sqi,sizeof(sqitype));
  48.            end;
  49.      while (fb^.status = StOk)
  50.      do    begin
  51.              if   Sqi.msgnum > SQZ
  52.              then begin
  53.                     sqz := sqi.MsgNum;
  54.                     inc(tempN);
  55.                     if Sqi.MsgNum > lhn
  56.                     then lhn := Sqi.MsgNum;
  57.                     sqi.msgnum := TempN;
  58.                     if   (Not ToYouOnly) or                          
  59.                          (SqHashName(StrPas(@MaxUserRec(Urec^.rec^).name)) = 
  60.                           Sqi.Hashname)
  61.                     then begin
  62.                             new(sqp);
  63.                             sqp^ := sqi;
  64.                             if sq = nil then new(sq,init(20,5));
  65.                             sq^.insert(sqp);
  66.                           end
  67.                    end
  68.              else inc(tempN);
  69.              fb^.read(sqi,sizeof(sqitype));
  70.            end;
  71.      dispose(fb,done);
  72.      if   lhn > sql
  73.      then begin
  74.             if   LRMCollection = Nil
  75.             then New(LRMCollection,init(10,5));
  76.             lhs := StrPas(@MaxAreaRec(Arec^.rec^).mpath) + '.SQL';
  77.             LRMCollection^.Insert(New(P0Base,init(newstr(lhs),
  78.                            LongInt((MaxUserRec(Urec^.rec^).lastread)),
  79.                            lhn,true)));
  80.           end;
  81.      NewSquishList := sq;
  82. End;
  83.  
  84.  
  85.